#include "mainwidget.h"

mainWidget::mainWidget(QWidget *parent)
    : QWidget(parent)
{
    this->resize(1400,800);//大小要刚好和图片相等。
    this->setWindowTitle("Deep-sea adventure~");//设置主窗口标题。

    this->setWindowIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/Icon.png"));//设置窗口图标，图标的名字.png写在括号里。

   /*//设置背景颜色：
    QPalette palette;//定义一个调色板；
    palette.setColor(QPalette::Background,Qt::darkCyan);
    this->setPalette(palette);
    */

    //设置背景图片：
    QPalette palette;
    palette.setBrush(QPalette::Background,QBrush(QPixmap("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/Background.jpg")));
    this->setPalette(palette);

    //游戏名标签初始化；
    this->label=new QLabel(this);
    label->setPixmap(QPixmap("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/label.png"));
    //this->label->setGeometry(40,20,2000,500);

    //添加start按钮；
    this->startbtn=new QPushButton(this);
    this->startbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/startbtn"));
    this->startbtn->setIconSize(QSize(480,125));
    this->startbtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //添加set按钮；
    //this->setbtn=new QPushButton(this);
    //this->setbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/setbtn"));
    //this->setbtn->setIconSize(QSize(330,69));
    //this->setbtn->setFlat(true);//去除底部白色边框；
    //this->setFocusPolicy(Qt::NoFocus);

    //添加
    this->helpbtn=new QPushButton(this);
    this->helpbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/helpbtn"));
    this->helpbtn->setIconSize(QSize(440,120));
    this->helpbtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //添加quit按钮
    this->quitbtn=new QPushButton(this);
    this->quitbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/quitbtn"));
    this->quitbtn->setIconSize(QSize(400,120));
    this->quitbtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //布局：
    this->vboxlayout=new QVBoxLayout(this);
    this->vboxlayout->addWidget(label);
    this->vboxlayout->addWidget(startbtn);
    this->vboxlayout->addWidget(helpbtn);
    this->vboxlayout->addWidget(quitbtn);
    //this->vboxlayout->addWidget(setbtn);
    this->vboxlayout->setAlignment(Qt::AlignCenter);


    level=new gamewidget(this);
    level->hide();

    help=new helpwidget(this);
    help->hide();
    // 信号和槽的关联：
    this->connect(startbtn,SIGNAL(clicked()),this,SLOT(startbtnclick()));
    this->connect(quitbtn,SIGNAL(clicked()),this,SLOT(quitbtnclick()));
    this->connect(helpbtn,SIGNAL(clicked()),this,SLOT(helpbtnclick()));

}

mainWidget::~mainWidget()
{
}
void mainWidget::startbtnclick()
{
    //level已经在mainwidget类里面定义了；
    level->show();
}
void mainWidget::quitbtnclick()
{
    if(QMessageBox::Yes==QMessageBox::question(this,"WARNING","Really want to leave?")) {
    this->close();
    }
}
void mainWidget::helpbtnclick()//**
{
    //help已经在mainwidget类里面定义了；
    help->show();
}

